//
//  YSLWelcomeView.m
//  used
//
//  Created by lanou on 16/7/28.
//  Copyright © 2016年 王凯. All rights reserved.
//

#import "YSLWelcomeView.h"
@interface YSLWelcomeView ()
@property (weak, nonatomic) IBOutlet UIImageView *sloganView;

@property (weak, nonatomic) IBOutlet UIImageView *appName;

@property (weak, nonatomic) IBOutlet UIImageView *iconView;

@end
@implementation YSLWelcomeView


+ (instancetype)weicomeView{
    return [[NSBundle mainBundle] loadNibNamed:@"YSLWelcomeView" owner:nil options:nil][0];
}
/*
 文字图片慢慢消失，alpha
 显示头像，头像往上移动的动画，弹簧效果
 欢迎回来的文字 慢慢显示 alpha
 */

- (void)didMoveToSuperview
{
    [super didMoveToSuperview];
    
    //    _iconView.layer.cornerRadius = 50;
    //    _iconView.layer.masksToBounds = YES;
    
    _iconView.transform = CGAffineTransformMakeTranslation(0, 100);
    [UIView animateWithDuration:0.5 animations:^{
        _sloganView.alpha = 0;
    } completion:^(BOOL finished) {
        _iconView.hidden = NO;
        
        [UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:0.3 initialSpringVelocity:0 options:UIViewAnimationOptionCurveLinear animations:^{
            _iconView.transform = CGAffineTransformIdentity;
        } completion:^(BOOL finished) {
            
            _appName.alpha = 0;
            _appName.hidden = NO;
            // 文字慢慢显示
            
            [UIView animateWithDuration:0.5 animations:^{
                _sloganView.alpha = 1;
                
            } completion:^(BOOL finished) {
                
                [UIView animateWithDuration:0.5 animations:^{
                    
                    self.alpha = 0;
                    
                } completion:^(BOOL finished) {
                    
                    [self removeFromSuperview];
                }];
                
            }];
            
        }];
        
    }];

}


@end
